OPEN INDOW (left; top; right; bottom; type; window title); close box)
                                                                                    Pg 48-8

left                Number         Pixels from left side of screen to left edge
top
               Number         Pixels from top of screen to top edge
right
             Number        Pixels from left side of screen to right edge
bottom
          Number        Pixels from top of screen to bottom edge
type                Number       Window type 
window title    String          Title of window
close box
      String          Procedure to call when close box is clicked

OPEN WINDOW opens a new window with the dimensions given by the first four parameters:

      • Left is the distance in pixels from the left edge of the screen to 
           the left internal edge of the window.

      • Top is the distance in pixels from the top of the screen to the top 
            internal edge of the window.

      • Right is the distance in pixels from the left edge of the screen to 
            the right internal edge of the window.

      • Bottom is the distance in pixels from the top of the screen to the 
          bottom internal edge of the window.

      • The type parameter is optional. It represents the type of window 
            you want to display, and corresponds to the different windows 
            shown earlier in this chapter. If the type of the window is 
            negative, the window created is a floating window. If the type is 
            not specified, type 1 is used by default.

      • The title parameter is the optional title for the window

      • The close box parameter is the optional close box procedure for 
           the window. If this parameter is specified, a close box is added 
           to the window. When the user clicks in the close box of a 
           window, the procedure passed in close box is called.

If more than one window is open for a process, the last window opened is the active (frontmost) window for that process. Only information within the active window can be modified. Any other windows can be viewed. When the user types, the active window will always come to the front, if it is not already in front.

Layouts are displayed inside an open window. Text from the  ESSAGE command also appears in the window.

To make your windows independent of display size, you can use Screen eight and Screen idth to calculate the upper-left and lower-right corners of the window. 

The following example demonstrates the use of OPEN WINDOW. The example prompts the user for the window height and width. It then uses that information to create a centered window. I he first global procedure calls the second procedure. Here is the first procedure:

      $wHeight:=200 
      $wWidth:=200 
      $wType:=0 
      $wTitle:="Hello World" 
      `
      Repeat 
          $wHeight:=Num(Request("Height (click cancel if 
                                                 done):";String($wHeight))) 
          If ((OK=1) & ($wHeight>0)) 
              $wWidth:=Num(Request("Width (click cancel if 
                                                  done):";String($wWidth))) 
              If ((OK=1) & ($wWidth>0)) 
                  $wType:=Num(Request("Window 
                                                 type:";String($wType))) 
                  If (OK=0) ` If you did not enter a window type
                      Center Window ($wWidth;$wHeight) ` Center window 
                                                                        ` with two parameters
                  Else
                      $wTitle:=Request("Window title:";$wTitle)
                      If (OK=0)      `  If you did not enter a window title
                          Center Window ($wWidth;$wHeight;$wType)
                                    ` Otherwise use all the parameters
                      else
                          Center Window ($wWidth;$wHeight;$wType;$wTitle)
                      End if
                  End if

              $Start:=Current time
              Repeat
                  GOTO XY((($wWidth\6)\2)-4;($wHeight\11 )\2)
                  MESSAGE(String(Current time-$Start))
              Until ((Current time$Start)>=†OO:00:10†)
              CLOSE WINDOW     ` Close the window
            End if
          End if
      Until (($wHeight=0) 1 ($wWidth=0))  ` Loop until request cancelled

The following code is the procedure Center Window, which opens a centered window. It is called by the first procedure. Notice that it can accept two, three, or four parameters:

$1 - Window width
$2 - Window height
$3 - Window type (optional)
$4 - Window title (optional)
$SW:=Screen width/2  ` Find center of screen (width)
$SH:=(Screen height/2)-10  ` Find center of screen (height)
$WW:=$1/2  ` Half of requested window width
$WH :=$2/2 ` Half of requested window height
      `
Case of
 : (Count parameters=2)
    OPEN WINDOW($SW-$WW;$SH-$WH;$SW+$WW;$SH+$WH)
 : (Count parameters=3)
    OPEN WINDOW($SW-$WW;$SH-$WH ;$SW+$WW;$SH+$WH ;$3)
 : (Count parameters=4)
    OPEN WINDOW($SW-$WW;$SH-$WH ;$SW+$WW;$SH+$WH ;$3;$4) 
End case

The following example opens a floating window which has a close box procedure: The window is opened in the upper right hand corner of the screen. Note the use of the Screen width function to make this procedure screen independent:

OPEN WINDOW(Screen width-149;33;Screen 
                                     width-4;178;-720;"";"CloseBox") 
DIALOG([Dialogs];"Color Palette")

The CloseBox just issues a call to the CANCEL command:

      CANCEL

See also:  ANCEL, Case f, CLOSE INDOW, 
               Count arameters, Current ime,  IALOG, 
               GOTO Y,  ESSAGE,  um,  equest, 
               Screen eight, Screen idth